#include "Scorer.h"

class Scorer2008 : public Scorer {
    public:
        virtual double score(Node* node) {
            double sum_e = node->sum_relative_areas();
            double area = width * height; //root->getArea(alpha, beta);
            double score = 0.0;
            vector<Node*> leaf_list;
            node->get_leafs(&leaf_list);
            if(node->get_width(alpha, beta) > width || node->get_height(alpha, beta) > height)
                return 0.0;
            for(int i = 0; i < leaf_list.size(); i++) {
                double ideal_area = (leaf_list.at(i)->get_image()->get_relative_area() / sum_e) * area;
                double individual_score = min(leaf_list.at(i)->get_image()->get_area() / ideal_area, 1.0);
                if(individual_score > 0.5)
                    score += individual_score;
            }
            return score;
        }
};
